<?php

namespace App\Http\Controllers\Api;

use App\Coach;
use Illuminate\Http\Request;

class CoachController extends BaseController
{
    public function list(Request $request)
    {
        $master = isset($request->master) ? $request->master : 0;
        $page = isset($request->page) ? $request->page : 1;
        $limit = isset($request->limit) ? $request->limit : 10;
        $sort = isset($request->sort) ? $request->sort : 'desc';
        $sortby = isset($request->sort) ? $request->limit : 'id';


        $data = Coach::where([
            ['status', 1],
            ['rec_status', $master]
        ])
            ->orderBy($sortby, $sort)
            ->offset(($page - 1) * $limit)
            ->limit($limit)
            ->get();

        return $this->apiResolveList($data, $page, $limit);
    }

    public function item(Request $request, Coach $coach)
    {
        return $this->apiResolveObject($coach);
    }

}
